import React from 'react';
import pic from '../assets/imgs/1.jpg';
import news from '../assets/css/news.css';

export default class News extends React.Component{
    constructor(props){
        super(props);
        this.state={
            msg:'新闻'
        }
        this.rows = [
            {title:111111},
            {title:222222},
            {title:333333}
        ]

    }
    setTest=(str)=>{
        this.setState({
            msg:'开始',
        },function () {
            this.stateFunction();
        })
        alert(this.state.msg);

    };
    printTest=()=>{
        alert(this.state.msg)
    }

    render(){
        let lst = this.rows.map(function (value,key) {
            return <li key={key}>{value.title}</li>
        })
        return(
            <div className="news">
                <img src={require('../assets/imgs/1.jpg')}/>
                <img src={pic} />
                {lst}
                <button onClick={this.setTest.bind(this,'联播')}>测试方法</button>
                <button onClick={this.printTest}>测试2</button>
            </div>
        )
    }
}